﻿using log4net;
using PcaCore.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace PcaParqueos.DAL
{
    public class dLiquidacion
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(dLiquidacion));

        #region public

        public static long Insert(string empresaId,
                                  string oficinaId,
                                  string usuarioId,
                                  long sesionId,
                                  string monedaId,
                                  decimal montoInicial)
        {
            try
            {
                //CREATE OR REPLACE FUNCTION pca_parqueos.fn_add_liquidacion(varchar,--empresa_id $1
                //               varchar,--oficina_id $2
                //               varchar,--usuario_id $3
                //               bigint,--sesion_id $4
                //               varchar,--moneda_id $5
                //               numeric --monto $6
                //               )RETURNS bigint
                object id = Core.ExecuteScalar("pca_parqueos.fn_add_liquidacion",
                                             new oParametro(NpgsqlTypes.NpgsqlDbType.Varchar, empresaId),
                                             new oParametro(NpgsqlTypes.NpgsqlDbType.Varchar, oficinaId),
                                             new oParametro(NpgsqlTypes.NpgsqlDbType.Varchar, usuarioId),
                                             new oParametro(NpgsqlTypes.NpgsqlDbType.Bigint, sesionId),
                                             new oParametro(NpgsqlTypes.NpgsqlDbType.Varchar, monedaId),
                                             new oParametro(NpgsqlTypes.NpgsqlDbType.Numeric, montoInicial));

                return Convert.ToInt64(id);
            }
            catch (Exception ex)
            {
                throw Core.LogException(log, ex, MethodBase.GetCurrentMethod().Name);
            }
        }

        #endregion
    }
}
